package edu.wtbu.cs.androiddemo.sqlite;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class SQLiteHelper extends SQLiteOpenHelper {
    public SQLiteHelper(Context context) {
        super(context, "userInfo.db", null, 2);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL("create table if not exists" + " userinfo" + "(" + "_id integer primary key " +
                "autoincrement," + "user_name varchar(20)," + "user_pwd varchar(20)," +
                "user_nick varchar(20) " + ")");

        db.execSQL("create table if not exists" + " orderInfo" + "(" + "_id integer primary key "
                + "autoincrement," + "goodsName varchar(50)," + "goodsPrice varchar(10)," +
                "goodsLocation varchar(50)," + "shopName varchar(50)," + "dateTime varchar(50)" +
                ")");
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("drop table if  exists userinfo");
        db.execSQL("drop table if  exists orderInfo");
        onCreate(db);
    }
}
